<template>
    <el-dialog :title="'新增'" :close-on-click-modal="false" :visible.sync="visible">
      <member-editor-inner ref="memberEditorInner"></member-editor-inner>

      <div slot="footer">
        <el-button @click="cancel()">取消</el-button>
        <el-button type="primary" @click="save()">新增</el-button>
      </div>
    </el-dialog>
</template>

<script>
import MemberEditorInner from './member-editor-inner'
export default {
  components: {
    MemberEditorInner
  },
  data () {
    return {
      visible: false
    }
  },
  methods: {
    async init (dept) {
      this.visible = true
      this.$nextTick(() => {
        this.$refs.memberEditorInner.init(dept, null)
      })
    },
    async save () {
      let success = await this.$refs.memberEditorInner.save()
      if (success) {
        this.visible = false
        this.$emit('refreshDataList')
      }
    },
    cancel () {
      this.visible = false
    }
  }
}
</script>
